package com.example.ch3_3.mapper;

import com.example.ch3_3.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    @Results(id="usermap", value = {
            @Result(property = "name", column = "username"),
            @Result(property = "password", column = "password"),
            @Result(property = "sex", column = "sex")
    })
    @Select("select * from user where username= #{username}")
    User getUserByName(@Param("username") String username);

    @Insert("insert into user(username,password,sex) values (#{name},#{password},#{sex})")
    int createUser(User user);

    @Select("select count(1) from user where username=#{name}")
    int findUserByname(@Param("name") String name);
}